package com.changgou.goods.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.goods.pojo.Category;
import com.changgou.goods.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description
 * @Author zhaoyang
 * @Date 2024/4/17 19:54
 */
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/list/{pid}")
    public Result<List<Category>> findByParentId(@PathVariable(value = "pid") Integer pid) {
        List<Category> categories = categoryService.findByParentId(pid);
        return new Result<>(true, StatusCode.OK, "查询成功", categories);
    }

}
